﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Selection.aspx.cs" Inherits="健康码管理系统.Selection" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <td>姓名:<asp:TextBox ID="TextBox1" runat="server" OnTextChanged="searchText_TextChanged"></asp:TextBox>
          &nbsp      <asp:Button ID="txtSelect" runat="server" Text="查询" /> &nbsp
                <asp:Button ID="txtAdd" runat="server" Text="添加" OnClick="txtAdd_Click"  PostBackUrl="~/Add.aspx"/>

            </td>
        </div>
       <div>
           <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource2" >
               <Columns>
                   <asp:BoundField DataField="UId" HeaderText="编号" InsertVisible="False" ReadOnly="True" SortExpression="UId" />
                   <asp:BoundField DataField="Name" HeaderText="姓名" SortExpression="Name" />
                   <asp:BoundField DataField="IdCard" HeaderText="身份证号" SortExpression="IdCard" />
                   <asp:BoundField DataField="PhoneNumber" HeaderText="电话号码" SortExpression="PhoneNumber" />
                   <asp:BoundField DataField="Sex" HeaderText="性别" SortExpression="Sex" />
                   <asp:BoundField DataField="Age" HeaderText="年龄" SortExpression="Age" />
                   <asp:BoundField DataField="CreateDate" HeaderText="登记时间" SortExpression="CreateDate" />
                   <asp:BoundField DataField="CId" HeaderText="健康码编号" SortExpression="CId" />
                   <asp:CheckBoxField DataField="State" HeaderText="是否上报" SortExpression="State" />
             
                   <asp:BoundField DataField="Expr2" HeaderText="健康码状态" SortExpression="Expr2" />
               </Columns>
           </asp:GridView>

           <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="Data Source=BEAKHYUN;Initial Catalog=Test2;User ID=sa;Password=123456;" DeleteCommand="DELETE FROM [UserInfo] WHERE [UId] = @UId" InsertCommand="INSERT INTO [UserInfo] ([Name], [IdCard], [PhoneNumber], [Sex], [Age], [CreateDate], [CId], [State]) VALUES (@Name, @IdCard, @PhoneNumber, @Sex, @Age, @CreateDate, @CId, @State)" SelectCommand="SELECT UserInfo.UId, UserInfo.Name, UserInfo.IdCard, UserInfo.PhoneNumber, UserInfo.Sex, UserInfo.Age, UserInfo.CreateDate, UserInfo.CId, UserInfo.State, Codetype.CId AS Expr1, Codetype.Name AS Expr2 FROM UserInfo INNER JOIN Codetype ON UserInfo.CId = Codetype.CId" UpdateCommand="UPDATE [UserInfo] SET [Name] = @Name, [IdCard] = @IdCard, [PhoneNumber] = @PhoneNumber, [Sex] = @Sex, [Age] = @Age, [CreateDate] = @CreateDate, [CId] = @CId, [State] = @State WHERE [UId] = @UId">
               <DeleteParameters>
                   <asp:Parameter Name="UId" Type="Int32" />
               </DeleteParameters>
               <InsertParameters>
                   <asp:Parameter Name="Name" Type="String" />
                   <asp:Parameter Name="IdCard" Type="String" />
                   <asp:Parameter Name="PhoneNumber" Type="String" />
                   <asp:Parameter Name="Sex" Type="String" />
                   <asp:Parameter Name="Age" Type="Int32" />
                   <asp:Parameter Name="CreateDate" Type="String" />
                   <asp:Parameter Name="CId" Type="Int32" />
                   <asp:Parameter Name="State" Type="Boolean" />
               </InsertParameters>
               <UpdateParameters>
                   <asp:Parameter Name="Name" Type="String" />
                   <asp:Parameter Name="IdCard" Type="String" />
                   <asp:Parameter Name="PhoneNumber" Type="String" />
                   <asp:Parameter Name="Sex" Type="String" />
                   <asp:Parameter Name="Age" Type="Int32" />
                   <asp:Parameter Name="CreateDate" Type="String" />
                   <asp:Parameter Name="CId" Type="Int32" />
                   <asp:Parameter Name="State" Type="Boolean" />
                   <asp:Parameter Name="UId" Type="Int32" />
               </UpdateParameters>
           </asp:SqlDataSource>
       </div>
    </form>
</body>
</html>
